<?php
/*
*	Kleophatra - Open Source Content Management System
*	------------------------------------------------------------------------
*	Copyright (C) 2007-2010, Sergio Milardovich <smilardovich@yahoo.com.ar>
*	This program is Free Software.
*
*	@package	Kleophatra
*	@subpackage	/lib
*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
*	@author		Sergio Milardovich <smilardovich@yahoo.com.ar>
*	@link		http://www.kleophatra.org
*/
class kleopackage extends kleotemplate{

	function download_package($filename, $repository, $path){

		$package = $repository.$path.$filename;
		$savefile = KLEO_SOURCE_DIR."tmp/{$filename}";
		$tmp_file = file_get_contents($package);

		$cutname = explode(".", $package);
		$name = "a";

		$fp = fopen($savefile, $name);
		fwrite($fp, $tmp_file);
		fclose ($fp);
		chmod($savefile, 0777);
		
	}

	function untar_package($package){
		$output = KLEO_SOURCE_DIR.'tmp/'.$package;
		system("tar -zxvf {$output}");
	}

	function check_package($package){

	}

	function load_package_info($file){
		$url = $file;
		if(file_exists($url)){
			$feed = file_get_contents($url);
			$this->apploadlib(KLEO_LIB_DIR."third_party/xml2array.lib.php", "xmltoarray", $xmltoarray);
			$package = $xmltoarray->xml2array($feed);
			return $package['package'];
		} else {
			return false;
		}
	}

}




?>
